package net.qhzw.vip.qiyu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import net.qhzw.vip.qiyu.entity.SysNotification;
import net.qhzw.vip.qiyu.mapper.SysNotificationMapper;
import net.qhzw.vip.qiyu.service.SysNotificationService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;


@Service
@Slf4j
public class SysNotificationServiceImpl extends ServiceImpl<SysNotificationMapper, SysNotification> implements SysNotificationService {

    /***
     * 分页查询通知管理
     * @param page
     * @param title
     * @param status
     * @return
     */
    @Override
    public Page<SysNotification> findByPage(Page<SysNotification> page, String title, Byte status) {
        return page(page, new LambdaQueryWrapper<SysNotification>()
                .eq(status != null, SysNotification::getStatus, status)
                .like(!StringUtils.isEmpty(title), SysNotification::getTitle, title)
                .last("ORDER BY `sort`,created DESC")
        );
    }
}
